"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Logger_1 = __importDefault(require("../utils/Logger"));
const Point_1 = require("./core/Point");
class Utils {
    getPointId(x, y) {
        return "(" + x.toFixed(1) + "," + y.toFixed(1) + ")";
    }
    getObj(method, data = null, isGame = true, isLog = true) {
        return { "isGame": isGame, "isLog": isLog, "method": method, "data": data };
    }
    /** 获取周围一圈point */
    getArrPointsAround(gameMgr, point) {
        let position = point.position;
        let arr_points = Array();
        let arr_pointIds = Array();
        arr_pointIds.push((this.getPointId(position.x - 0.5, position.y + 1)));
        arr_pointIds.push((this.getPointId(position.x + 0.5, position.y + 1)));
        arr_pointIds.push((this.getPointId(position.x - 1, position.y)));
        arr_pointIds.push((this.getPointId(position.x + 1, position.y)));
        arr_pointIds.push((this.getPointId(position.x - 0.5, position.y - 1)));
        arr_pointIds.push((this.getPointId(position.x + 0.5, position.y - 1)));
        for (let pointId of arr_pointIds) {
            let p = gameMgr.map_point.get(pointId);
            if (p != null) {
                arr_points.push(p);
            }
        }
        return arr_points;
    }
    /** 获取周围第二圈point */
    getArrPointsAround2(gameMgr, point) {
        let position = point.position;
        let map_points = gameMgr.map_point;
        let arr_points = Array();
        let arr_pointIds = Array();
        arr_pointIds.push((this.getPointId(position.x - 1, position.y + 2)));
        arr_pointIds.push((this.getPointId(position.x, position.y + 2)));
        arr_pointIds.push((this.getPointId(position.x + 1, position.y + 2)));
        arr_pointIds.push((this.getPointId(position.x - 1.5, position.y + 1)));
        arr_pointIds.push((this.getPointId(position.x + 1.5, position.y + 1)));
        arr_pointIds.push((this.getPointId(position.x - 2, position.y)));
        arr_pointIds.push((this.getPointId(position.x + 2, position.y)));
        arr_pointIds.push((this.getPointId(position.x - 1.5, position.y - 1)));
        arr_pointIds.push((this.getPointId(position.x + 1.5, position.y - 1)));
        arr_pointIds.push((this.getPointId(position.x - 1, position.y - 2)));
        arr_pointIds.push((this.getPointId(position.x, position.y - 2)));
        arr_pointIds.push((this.getPointId(position.x + 1, position.y - 2)));
        for (let pointId of arr_pointIds) {
            var p = map_points.get(pointId);
            if (p != null) {
                arr_points.push(p);
            }
        }
        Logger_1.default.log(arr_points);
        return arr_points;
    }
    /** 获取第一圈+第二圈的point */
    getArrPointsAround1And2(gameMgr, point) {
        let arr_total = Array();
        let arr_points_1 = this.getArrPointsAround(gameMgr, point);
        let arr_points_2 = this.getArrPointsAround2(gameMgr, point);
        for (let p of arr_points_1) {
            arr_total.push(p);
        }
        for (let p of arr_points_2) {
            arr_total.push(p);
        }
        return arr_total;
    }
    /** 秒数转时间 */
    secondToTime(second) {
        let minute = Math.floor(second / 60);
        let str_minute = "";
        if (minute < 10) {
            str_minute = "0" + minute;
        }
        else {
            str_minute = "" + minute;
        }
        let remain = second % 60;
        let str_remain = "";
        if (remain < 10) {
            str_remain = "0" + remain;
        }
        else {
            str_remain = "" + remain;
        }
        return str_minute + ":" + str_remain;
    }
    /** 敲山震虎 获得的pointList */
    getArrPointsAsShan(gameMgr, point, list) {
        point.is_敲山震虎_flag = true;
        let arr = this.getArrPointsAround(gameMgr, point);
        for (let p of arr) {
            if (p.terrain != Point_1.Terrain.SHAN) {
                continue;
            }
            if (p.is_敲山震虎_flag) {
                continue;
            }
            this.getArrPointsAsShan(gameMgr, p, list);
        }
        return list;
    }
}
exports.default = new Utils();
